<template>
  <div class="form">
    <el-dialog
      width="55%"
      :visible.sync="dialogFormVisible"
      title="账户流水"
      @close="cancel"
    >
      <el-table
        :data="tableList"
        border
        style="margin: 10px 0"
        v-loading="loading"
      >
        <el-table-column
          prop="business_code"
          label="业务类型"
          width="120"
          align="center"
        >
        </el-table-column>
        <el-table-column
          prop="money"
          label="变动金额(￥)"
          width="120"
          align="center"
        >
        </el-table-column>
        <el-table-column
          prop="before_balance"
          label="变动前可用余额(￥)"
          width="160"
          align="center"
        >
        </el-table-column>
        <el-table-column
          prop="after_balance"
          label="变动后可用余额(￥)"
          width="160"
          align="center"
        >
        </el-table-column>
        <el-table-column
          prop="create_time"
          label="创建时间"
          width="180"
          align="center"
        >
        </el-table-column>
      </el-table>
      <pagination
        :page="params.page"
        :page_size="params.page_size"
        :total="total"
        @currentChange="currentChange"
        @sizeChange="sizeChange"
      ></pagination>
    </el-dialog>
  </div>
</template>

<script>
import { logs } from "@/api/account"
export default {
  name: "my-form",
  data() {
    return {
      dialogFormVisible: false,
      loading: true,
      params: {
        page: 1,
        page_size: 10,
        business_code: "",
        fund_id: "",
      },
      total: 0,
      tableList: [],
    }
  },
  methods: {
    show(e) {
      const { fund_id } = e
      this.params.fund_id = fund_id
      this.getLogs()
    },
    async getLogs() {
      try {
        const { data } = await logs(this.params)
        this.loading = false
        this.tableList = data.data
        this.total = data.total
        this.dialogFormVisible = true
      } catch (ex) {
        this.loading = false
        this.$msg.errorMsg(ex.msg)
      }
    },
    // 取消
    cancel() {
      this.loading = true
      this.dialogFormVisible = false
    },
    // 分页
    sizeChange(e) {
      this.params.page_size = e
      this.getLogs()
    },
    currentChange(e) {
      this.params.page = e
      this.getLogs()
    },
  },
}
</script>

<style lang="scss" scoped></style>
